﻿using DAL.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAL.Persistencia
{
    public class Quotation_TourMapDAL
    {
        NewTierraEntities Con;

        public Quotation_TourMapDAL()
        {
            Con = new NewTierraEntities();
        }

        public int Adicionar(Quotation_TourMap qtm)
        {
            try
            {
                Con.AddToQuotation_TourMap(qtm);
                Con.SaveChanges();
                return qtm.tourMap_Id;
            }
            catch (Exception)
            {
                
                throw;
            }
        }

        public void Atualizar(Quotation_TourMap qtm)
        {
            try
            {
                Quotation_TourMap old = ObterPorQuotationGrupoID(qtm.tourMap_QuotationGroup_ID);
                old.tourMap_Path = qtm.tourMap_Path;
                Con.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }
        }

        public Quotation_TourMap ObterPorQuotationGrupoID(int QuotationGroupID)
        {
            try
            {
                return Con.Quotation_TourMap.Where(a => a.tourMap_QuotationGroup_ID == QuotationGroupID).FirstOrDefault();
            }
            catch (Exception)
            {   
                throw;
            }
        }
    }
}
